import React from 'react';
import ReactDOM from 'react-dom';
import $ from "jquery";
import "./library/jstree/themes/default/style.min.css"
import ReactTree from "./components/Application.react";

class ExampleApp extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            data:null,
            items:[]
        }
    }

    componentWillMount(){
        $.ajax({
            url:"./source/JSTree/JSON/department.json",
            async:false,  //Ajax异步操作，如果不设置同步，初始加载data = null；
            success:(data)=>{
                this.setState({
                    data:data
                })
            }
        })
    }

    componentDidMount(){

    }


    render() {
        return (
            <div>
                <ReactTree core={this.state.data} onChanged={this.handleOnChanged} />
                <div>Selected items: {this.state.items}</div>
            </div>
        );
    }
}
ReactDOM.render(<ExampleApp />,document.getElementById('root'));